@extends('backend::layout')
@section('title',$page_title)
@push('styles')
    <link href="{{asset(config('view.plugin').'/layui/layui_ext/cascader/cascader.css')}}" rel="stylesheet">
@endpush
@include('backend::component.upload.upload_js')
@section('content')
    <div class="row">
        <div class="col-lg-12">
            @if($info)
                @component('backend::component.form.form')
                    @slot('form_title') {{$page_title}} @endslot
                    @slot('formId') edit-article @endslot
                    @slot('enctype') multipart/form-data @endslot
                    @slot('action') {{route('b_Article_editArticle',['id'=>$info->id])}} @endslot

                        @component('backend::component.form.form-group')
                            @slot('title') 文章标题 @endslot
                            @component('backend::component.form.input')
                                @slot('name') title @endslot
                                @slot('value') {{$info->title}} @endslot
                            @endcomponent
                        @endcomponent

                        @component('backend::component.form.form-group')
                            @slot('title') 副标题 @endslot
                            @component('backend::component.form.input')
                                @slot('name') subtitle @endslot
                                @slot('value') {{$info->subtitle}} @endslot
                            @endcomponent
                        @endcomponent

                        @component('backend::component.form.form-group')
                            @slot('title') 文章分类 @endslot
                            <div class="layui-input-block">
                                <input type="text" id="category"
                                       data-categories='{{$categories}}'
                                       data-default="{{$info->cat_id}}"
                                       class="form-control" readonly
                                >
                                <input type="hidden" id="cat-value" name="cat_id"  value="{{$info->cat_id}}">
                            </div>
                        @endcomponent

                        @component('backend::component.form.form-group')
                            @slot('title') 文章封面 @endslot
                            @component('backend::component.upload.upload_img',['imgList'=>[$info->thumb=>$info->thumb]])
                                @slot('name') thumb @endslot
                                @slot('group') article @endslot
                                @slot('value') {{$info->thumb}} @endslot
                            @endcomponent
                        @endcomponent

{{--                        @component('backend::component.form.form-group')--}}
{{--                            @slot('title') 上传音频-听录音分类有效 @endslot--}}

{{--                            @if($info->mp3)--}}
{{--                                <div class="form-group">--}}
{{--                                    <audio src="{{$info->mp3}}" controls="controls">--}}
{{--                                        您的浏览器不支持--}}
{{--                                    </audio>--}}
{{--                                </div>--}}
{{--                            @endif--}}

{{--                            @component('backend::component.form.input')--}}
{{--                                @slot('name') mp3 @endslot--}}
{{--                                @slot('type') file @endslot--}}
{{--                                @slot('value')  @endslot--}}
{{--                            @endcomponent--}}
{{--                        @endcomponent--}}

{{--                        @component('backend::component.form.form-group')--}}
{{--                            @slot('title') 上传视频-看视频分类有效 @endslot--}}

{{--                            @if($info->mp4)--}}
{{--                                <div class="form-group">--}}
{{--                                    <video style="width: 100%" src="{{$info->mp4}}" controls="controls">--}}
{{--                                        您的浏览器不支持--}}
{{--                                    </video >--}}
{{--                                </div>--}}
{{--                            @endif--}}

{{--                            @component('backend::component.form.input')--}}
{{--                                @slot('name') mp4 @endslot--}}
{{--                                @slot('type') file @endslot--}}
{{--                                @slot('value')  @endslot--}}
{{--                            @endcomponent--}}
{{--                        @endcomponent--}}

                        @component('backend::component.form.form-group')
                            @slot('title') 内容 @endslot
                            @component('backend::component.ckedit')
                                @slot('name') content @endslot
                                @slot('value') {{$info->content}} @endslot
                                 @slot('loading_js') true @endslot
                            @endcomponent
                        @endcomponent

                        @component('backend::component.form.form-group')
                            @slot('title') 排序 @endslot
                            @component('backend::component.form.input')
                                @slot('name') sort @endslot
                                @slot('value') {{$info->sort ?? '1000'}} @endslot
                            @endcomponent
                        @endcomponent

                        @component('backend::component.form.form-group')
                            @slot('title') 描述 @endslot
                            @component('backend::component.form.textarea')
                                @slot('name') description @endslot
                                @slot('value') {{$info->description}}  @endslot
                            @endcomponent
                        @endcomponent

                        @component('backend::component.form.form-group')
                            @slot('title') 关键词 @endslot
                            @component('backend::component.form.textarea')
                                @slot('name') key_words @endslot
                                @slot('value') {{$info->keywords}} @endslot
                            @endcomponent
                        @endcomponent


                    @slot('buttons')
                            <button type="submit" class="btn-min-width btn btn-sm btn-primary mr-1" data-params="{&quot;formId&quot;:&quot;#add-article&quot;}">
                                提交
                            </button>
{{--                        @component('backend::component.form.button')--}}
{{--                            @slot('title') 提交 @endslot--}}
{{--                            @slot('params') {"formId":"#edit-article"} @endslot--}}
{{--                            @slot('class') btn-min-width ajax-form @endslot--}}
{{--                        @endcomponent--}}
                        @component('backend::component.form.button')
                            @slot('title') 重置 @endslot
                            @slot('type') reset @endslot
                            @slot('color') danger @endslot
                            @slot('class') btn-min-width @endslot
                        @endcomponent
                    @endslot
                @endcomponent
            @else
                @include('backend::public.empty_page',['info'=>'修改信息不存在'])
            @endif
        </div>
        <!--/.col-->
    </div>
@endsection
@push('scripts')
    <script>
        layui.use(['jquery','cascader'], function(){
            var $ = layui.jquery;
            var cascader = layui.cascader;
            selectParentAction();
            function selectParentAction() {
                var data = $('#category').data('categories');
                var defaultVal = $('#category').data('default').toString();
                if(defaultVal&&defaultVal.indexOf(",") != -1){
                    var defaultValArr = defaultVal.split(",")
                }else{
                    var defaultValArr = [defaultVal?defaultVal:0];
                }
                cascader({
                    elem: "#category",
                    data: data,
                    triggerType: "change",
                    value: defaultValArr,
                    changeOnSelect:true,
                    success:function (valData) {
                        $('#cat-value').val(valData[valData.length-1]);
                    }
                });
            }
        });
    </script>
@endpush